package sr.codemg.service.impl;

import sr.codemg.entity.SrGroupMember;
import sr.codemg.mapper.SrGroupMemberMapper;
import sr.codemg.utils.ResponseCode;
import sr.codemg.utils.StaticFunc;
import sr.codemg.vm.Base;
import sr.codemg.vm.Tables;
import sr.codemg.vm.Selects;
import sr.codemg.service.SrGroupMemberService;
import sr.codemg.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 我的项目
 **/
@Service
public class SrGroupMemberServiceImpl implements SrGroupMemberService {

    @Autowired
    SrGroupMemberMapper srGroupMemberMapper;

    @Override
    public SrGroupMember get(String id) {
        return srGroupMemberMapper.get(id);
    }

    @Override
    public Tables findList(Map<String, Object> params) {
        StaticFunc.page(params);
        List<SrGroupMember> data = srGroupMemberMapper.findList(params);
        Integer count = srGroupMemberMapper.count(params);
        return new Tables(data, count);
    }

    @Override
    public Base.Response add(SrGroupMember entity) {
        entity.setMaxMember("5");
        entity.setCrtTs(StaticFunc.date());
        srGroupMemberMapper.add(entity);
        return ResponseCode.getBase(Constants.SUCC);
    }

    @Override
    public Base.Response update(SrGroupMember entity) {
        srGroupMemberMapper.update(entity);
        return ResponseCode.getBase(Constants.SUCC);
    }

    @Override
    public Base.Response delete(String id) {
        srGroupMemberMapper.delete(id);
        return ResponseCode.getBase(Constants.SUCC);
    }

    @Override
    public Selects.Response select(Selects.Request req) {
        req.configPage();
        List<Selects.Select> data = srGroupMemberMapper.select(req);
        Selects.Response res = new Selects.Response();
        res.setData(data);
        return res;
    }
}

